<div class="pageContent">
    <form method="post"
        action="${rc.getContextPath()}/manage/messageRule/saveMessageRule"
        class="pageForm required-validate"
        onsubmit="return validateCallback(this, dialogAjaxDone);">
        <div class="pageFormContent" layoutH="120">
            <input type="hidden" name="navTabId" value="">
            	<input type="hidden" name="id"
                value="<#if (messageRule.id)??>${messageRule.id!''}</#if>">
            
            <fieldset class="dataset">
                <dl>
                    <dt><@label key="messageRuleCode.C,colon">消息规则编号：</@label></dt>
                    <dd>
                        <input name="ruleCode"
                            size="32" type="text" maxlength="20" class="required alphanumeric toUp textInput" 
                            value="${messageRule.ruleCode!''}" readonly="readonly"
                        /> 
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="desc.C,colon">描述：</@label></dt>
                    <dd>
                        <input name="ruleText"
                            size="32" type="text" maxlength="60" class="textInput " 
                            value="${messageRule.ruleText!''}" readonly="readonly"
                        /> 
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="andonType.C,colon">ANDON类型：</@label></dt>
                    <dd>
                        <select name="andonTypeCode" disabled="disabled">
                            <option value="" ><@label key="all.C">所有</@label></option>
                            <#list andonTypeList  as andonType>
                            <option value="${andonType.andonTypeCode}"<#if  (messageRule)?? && andonType.andonTypeCode == messageRule.andonTypeCode> selected="selected"</#if>>${andonType.typeText}</option>
                            </#list>
                        </select>
                    </dd>
                </dl>
                <dl>
                    <dt>&nbsp;</dt>
                    <dd>
                        <label style="width:80px;">
                            <input name="lockFlag" type="checkbox" value="1"  disabled="disabled" <#if (messageRule)?? && 1==messageRule.lockFlag>checked=true</#if>/> 
                            <@label key="lock.C">锁定</@label>
                        </label>
                    </dd>
                </dl>
                <dl  class="nowrap">
                    <dt><@label key="andonChoose.C,colon">ANDON选择：</@label></dt>
                    <dd>
                        <div style="float:left;'">
                        <input name="allAndonsFlag" type="checkbox" value="1"  disabled="disabled" <#if (messageRule)?? && 1==messageRule.allAndonsFlag>checked=true</#if>/> 
                        <@label key="all.C">所有</@label>
                        </div>
                    </dd>
                </dl>
                <dl  class="nowrap">
                        <div>
                            <table class="table border" width="100%" layoutH="430">
                                <thead>
                                    <tr>
                                        <th width="100"><@label key="workCenter.C">工作中心</@label></th>
                                        <th width="100"><@label key="workUnit.C">作业单元</@label></th>
                                        <th width="100"><@label key="type.C">类型</@label></th>
                                        <th width="100"><@label key="andonCode.C">ANDON编号</@label></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <#if (messageRule)?? && (messageRule.messageRuleAndonAssignList)??>
                                    <#list messageRule.messageRuleAndonAssignList as messageRuleAndonAssign>
                                        <tr name="${messageRuleAndonAssign.workUnitCode}_${messageRuleAndonAssign.andonCode}">
                                            <td><input type='hidden'  name='messageRuleAndonAssignList[${messageRuleAndonAssign_index}].workUnitCode' value="${messageRuleAndonAssign.workUnitCode!''}"/><input type='hidden'  name='messageRuleAndonAssignList[${messageRuleAndonAssign_index}].andonCode'  value="${messageRuleAndonAssign.andonCode!''}"/>${messageRuleAndonAssign.workCenterText!''}</td>
                                            <td>${messageRuleAndonAssign.workUnitText!''}</td>
                                            <td>${messageRuleAndonAssign.andonTypeText!''}</td>
                                            <td>${messageRuleAndonAssign.andonCode!''}</td>
                                        </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                        </div>
                </dl>
                <dl  class="nowrap">
                        <div>
                            <table class="table border" width="100%" layoutH="430">
                                <thead>
                                    <tr>
                                        <th width="100"><@label key="noticePeriod.C">通知时段</@label></th>
                                        <th width="50"><@label key="timerStartEcode.C">计时起点</@label></th>
                                        <th width="50"><@label key="monitorStatus.C">监控状态</@label></th>
                                        <th width="60"><@label key="messageReceiveUser.C">消息接收人</@label></th>
                                        <th width="40"><@label key="timeInterval.C">升级时限</@label></th>
                                        <th width="100"><@label key="messageTemplate.C">消息模版</@label></th>
                                    </tr>
                                </thead>
                                <tbody name='messageRuleItem_tbody'>
                                    <#if (messageRule)?? && (messageRule.messageRuleItemList)??>
                                    <#list messageRule.messageRuleItemList as messageRuleItem>
                                        <tr ref="${messageRuleItem.id}">
                                            <td><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].periodStart' value="${messageRuleItem.periodStart!''}"/><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].periodEnd'  value="${messageRuleItem.periodEnd!''}"/>${messageRuleItem.periodStart!''} - ${messageRuleItem.periodEnd!''}</td>
                                            <td><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].timerStartEcode' value="${messageRuleItem.timerStartEcode!''}"/>${messageRuleItem.timerStartEcodeText!''}</td>
                                            <td><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].statusEcode' value="${messageRuleItem.statusEcode!''}"/>${messageRuleItem.statusEcodeText!''}</td>
                                            <td><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].receiveUser' value="${messageRuleItem.receiveUser!''}"/>${messageRuleItem.receiveUserText!''}</td>
                                            <td><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].timeInterval'  value="${messageRuleItem.timeInterval!''}"/>${messageRuleItem.timeInterval!''}</td>
                                            <td><input type='hidden'  name='messageRuleItemList[${messageRuleItem_index}].messageCode'  value="${messageRuleItem.messageCode!''}"/>${messageRuleItem.messageText!''}</td>
                                        </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                        </div>
                </dl>
            </fieldset>
        </div>
         <#if (messageRule)??>
            <#assign createInfo=messageRule>
            <#include "/common/createInfo.html">
        </#if>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive" style="margin-left: 10px;">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label
                                key="close.B">关闭</@label></button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script type="text/javascript">


(function($){
    var page = DWZ.context();
    var messageRuleItemTbody = $("tbody[name='messageRuleItem_tbody']",page);
    var messageRuleItemrowNumber = $("tr",messageRuleItemTbody).length;
    
    $.messageRule = {
    		bringBackToRuleItemGrid : function(data){
    			var page = DWZ.context();
    			var prefix = "messageRuleItemList["+messageRuleItemrowNumber+"]"
    			
    			var trHtml = "<tr><td><input type='checkbox' name='rule_id'></td>"
    			trHtml += "<td><input type='hidden'  name='"+prefix+".periodStart'/>"+
    			              "<input type='hidden'  name='"+prefix+".periodEnd'/>"+data.periodStart +" - "+ data.periodEnd+"</td>";
    			trHtml += "<td><input type='hidden'  name='"+prefix+".timerStartEcode'/>"+data.timerStartEcodeText+"</td>";
    			trHtml += "<td><input type='hidden'  name='"+prefix+".statusEcode'/>"+data.statusEcodeText+"</td>";
    			trHtml += "<td><input type='hidden'  name='"+prefix+".receiveUser'/>"+data.receiveUserText+"</td>";
    			trHtml += "<td><input type='hidden'  name='"+prefix+".timeInterval'/>"+data.timeIntervalText+"</td>";
    			trHtml += "<td><input type='hidden'  name='"+prefix+".messageCode'/>"+data.messageCodeText+"</td>";
    			trHtml += "</tr>";
    			
    			messageRuleItemTbody.append(trHtml);
    			
    			$.each(data,function(name,value){
    				$("input[type='hidden'][name='"+prefix+"."+name+"']",$("tr:last",messageRuleItemTbody)).val(value);
    			});
    			
    			 $.jTableTool.initGridColumnWidth(messageRuleItemTbody.parents(".grid"));
    			 
    			 messageRuleItemrowNumber++;
    	    }
    }
    
    

    
    $("a[name='btnMessageRuleItemDel']",page).on("click",function(){
        $.each($("input[type='checkbox']:checked",messageRuleItemTbody),function(index,el){
        	var trEl = $(el).parents("tr");
        	if(trEl.attr("ref")){
        		$("input[group='delete']",trEl).val("true");
        		trEl.hide();
        	}else{
        		trEl.remove();
        	}
        	
        })
    })
    
    
    $("button[name='btnAndonSelect']",page).on('click',function(){
    	$.pdialog.open("${rc.getContextPath()}/manage/andon/andonLookUp","messageRuleItemAdd_dialog","ANDON选择",{
            width : 1500,
            height : 550,
            minable : false,
            mask : true,
            resizable : true
        });
    })
})(jQuery);
</script>
